<!--  -->
<template>
    <div>
      <mt-header title="地址管理">
      <router-link  to  slot="left">
        <mt-button icon="back" @click="$router.back(-1)" style="color:black"></mt-button>
      </router-link>
      <mt-button icon="more" slot="right"></mt-button>
      </mt-header>
      <div class="border">
        <div class="content" v-for="item in Adressinfo" :key="item.Aid">
            <div class="text">
              <div>
                <p>{{ item.Name }}</p>
                <p>{{ item.Phone }}</p>
                <span class="logo" v-if="item.IsAdress==0">默认</span>
              </div>
              <div>
                  <p>{{ item.Province }}</p>
                  <p>{{ item.city }}</p>
                  <p>{{ item.District }}</p>
                  <p>{{ item.AdressDetail }}</p>
              </div>
            </div>
            <div class="butt" @click="setAdress(item.Aid)">
              <img src="../assets/img/修改.png" alt="">
            </div>
        </div>
        <div class="out">
          <div class="button" @click="Add()" >
          <p>新增地址</p>
          </div>  
        </div>
      </div>
    </div>
    </template>
    
    <script>
    export default {
    data() {
    return {
      Adressinfo:[]
    }
    },
    //生命周期 - 创建完成（访问当前this实例）
    created() {
    
    },
    //生命周期 - 挂载完成（访问DOM元素）
    mounted() {
       // 判断登录状态
    let userInfo=JSON.parse(localStorage.getItem("userInfo")); //去除localStoreage中的登录状态
        this.getAdress(userInfo.uid)
    },
    methods:{
        Add(){
            // console.log("点击")
            this.$router.push("/AddAdress")
        },
        getAdress(uid){
          var url= `/GetUserAdress?uid=${uid}`
          // console.log(url)
          this.axios.get(url).then(res=>{
            console.log(res)
            this.Adressinfo=res.data.result
          })
        },
        setAdress(Aid){
          console.log("点击：",Aid)
          this.$router.push({
            path:`/EditAdress/${Aid}`
          })
        },
    }
    }
    </script>
    <style scoped>
    /* @import url(); 引入css类 */
    .mint-header{
        color: black;
        background-color: white;
        font-size: 10px;
    }
    
    .border{
      margin: 20px 10px;
      margin-bottom: 50px;
    }
    .border .content{
      display: flex;
      padding-bottom: 20px;
    }
    .border .text {
      display: inline-block;
      /* background-color: aqua; */
      width: 80%;
      /* height: 0px; */
      font-size: 10px;
      padding-left: 20px;
    }
    .border .text p{
      display: inline-block;
      padding: 4px;

    }
    .border .butt{
      width: 20%;
      /* background-color: rgb(28, 172, 90); */
      text-align: center;
      position: relative;
    }
    .border .butt img{
      width: 18px;
      height: 18px;
      /* text-align: center; */
      position: absolute;
      left: 50%;
      top: 50%;
      transform:translate(-50%,-50%);
    }
    
    .out{
      /* margin: 15px 8%; */
        position: fixed;
        bottom: 0;
        background-color: white ;
    }
    .button{
    width: 80%;
    padding: 0px 8% 15px 8%;
    position: fixed;
    bottom: 0;
    background-color: white;
}
.button p{
    background-color: rgb(27, 174, 174);
    color: white;
    width: 100%;
    text-align: center;
    font-size: 10px;
    border-radius: 20px;
    line-height: 30px;
}


.logo{
  color: aliceblue;
  background-color: red;
  padding: 0 5px;

}
    
    </style>